﻿package
{
	
	import controller.*;
	
	import org.puremvc.as3.patterns.facade.Facade;

	/**
	 * Facade模式来实现统一的接口，对外只提供了startup方法用于启动
	 * 在该类被创建的时候会自动调用initializeController方法，需要在该方法中对Command进行注册
	 * 接着，调用startup方法启动（也就是发送一个消息，因为之前已经注册了Command,所以相应的方法会去执行execute进行响应）。
	 * @author ...
	 */
	public class ApplicationFacade extends Facade
	{
		

		public static function getInstance():ApplicationFacade
		{
			if (instance == null)
			{
				instance=new ApplicationFacade();
			}
			return instance as ApplicationFacade;
		}

		public function startup(app:Object):void
		{
			sendNotification(AllNotification.START_UP, app);
		}

		/**启动MVC会自动执行这个覆盖类  注册所有的Command类与消息绑定*/
		override protected function initializeController():void
		{

			super.initializeController();

			registerCommand(AllNotification.START_UP, StartUpCommand);
			registerCommand(AllNotification.MOUSE_CLICK, MouseClickCommand);
			registerCommand(AllNotification.MOUSE_CLICK, MouseClickYCommand);
			registerCommand(AllNotification.KEY_CLICK, KeyClickCommand);
			registerCommand(AllNotification.INIT_LOAD_ALL,InitLoadCommand);
			
		}
	}
}
